home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 June / PCWorld_2007-06_cd.bin / v cisle / tclock / tclocklight-040702-3.exe / source / property / pagemouse.c < prev    next >
C/C++ Source or Header  |  2004-06-30  |  16KB  |  591 lines

  1. /*-------------------------------------------------------------
  2.   pagemouse.c : "Mouse" - "Click" page of properties
  3.   (C) Kazuto Sato 1997-2003
  4.   For the license, please read readme.txt.
  5.   
  6.   Written by Kazubon, Nanashi-san
  7. ---------------------------------------------------------------*/
  8.  
  9. #include "tcprop.h"
  10. #include "../common/command.h"
  11.  
  12. /* Globals */
  13.  
  14. BOOL CALLBACK PageMouseProc(HWND hDlg, UINT message,
  15.     WPARAM wParam, LPARAM lParam);
  16.  
  17. /* Statics */
  18.  
  19. static void SendPSChanged(HWND hDlg);
  20. static void OnInit(HWND hDlg);
  21. static void OnDestroy(HWND hDlg);
  22. static void OnApply(HWND hDlg);
  23. static void OnName(HWND hDlg);
  24. static void OnNameDropDown(HWND hDlg);
  25. static void OnAdd(HWND hDlg);
  26. static void OnDelete(HWND hDlg);
  27. static void OnFunction(HWND hDlg, BOOL bInit);
  28. static void OnBrowse(HWND hDlg);
  29. static void SetMouseCommandToDlg(HWND hDlg, PMOUSESTRUCT pMSS);
  30. static void GetMouseCommandFromDlg(HWND hDlg, PMOUSESTRUCT pMSS);
  31. static void EnableMousePageItems(HWND hDlg);
  32. static void InitFunction(HWND hDlg, int id);
  33.  
  34. static BOOL  m_bInit = FALSE;
  35. static BOOL  m_bChanged = FALSE;
  36.  
  37. static char *m_section = "Mouse";
  38. static PMOUSESTRUCT m_pMouseCommand = NULL;
  39. static int m_numMouseCommand = 0;
  40. static int m_numOld = 0;
  41. static int m_nCurrent = -1;
  42. static int m_widthOpt = 0;
  43.  
  44. /*------------------------------------------------
  45.   Dialog procedure
  46. --------------------------------------------------*/
  47. BOOL CALLBACK PageMouseProc(HWND hDlg, UINT message,
  48.     WPARAM wParam, LPARAM lParam)
  49. {
  50.     switch(message)
  51.     {
  52.         case WM_INITDIALOG:
  53.             OnInit(hDlg);
  54.             return TRUE;
  55.         case WM_DESTROY:
  56.             OnDestroy(hDlg);
  57.             break;
  58.         case WM_COMMAND:
  59.         {
  60.             WORD id, code;
  61.             id = LOWORD(wParam); code = HIWORD(wParam);
  62.             switch(id)
  63.             {
  64.                 case IDC_NAMECLICK:
  65.                     if(code == CBN_SELCHANGE)
  66.                     {
  67.                         m_bInit = FALSE;
  68.                         OnName(hDlg);
  69.                         m_bInit = TRUE;
  70.                     }
  71.                     else if(code == CBN_DROPDOWN)
  72.                         OnNameDropDown(hDlg);
  73.                     else if(code == CBN_EDITCHANGE)
  74.                         SendPSChanged(hDlg);
  75.                     break;
  76.                 case IDC_ADDCLICK:
  77.                     OnAdd(hDlg);
  78.                     break;
  79.                 case IDC_DELCLICK:
  80.                     OnDelete(hDlg);
  81.                     break;
  82.                 case IDC_MOUSEBUTTON:
  83.                     if(code == CBN_SELCHANGE)
  84.                         SendPSChanged(hDlg);
  85.                     break;
  86.                 case IDC_RADSINGLE:
  87.                 case IDC_RADDOUBLE:
  88.                 case IDC_RADTRIPLE:
  89.                 case IDC_RADQUADRUPLE:
  90.                 case IDC_MOUSECTRL:
  91.                 case IDC_MOUSESHIFT:
  92.                 case IDC_MOUSEALT:
  93.                 case IDC_RCLICKMENU:
  94.                     SendPSChanged(hDlg);
  95.                     break;
  96.                 case IDC_MOUSEFUNC:
  97.                     OnFunction(hDlg, FALSE);
  98.                     break;
  99.                 case IDC_MOUSEOPT:
  100.                     if(code == EN_CHANGE)
  101.                         SendPSChanged(hDlg);
  102.                     break;
  103.                 case IDC_MOUSEOPTSANSHO:
  104.                     OnBrowse(hDlg);
  105.                     break;
  106.             }
  107.             return TRUE;
  108.         }
  109.         case WM_NOTIFY:
  110.             switch(((NMHDR *)lParam)->code)
  111.             {
  112.                 case PSN_APPLY: OnApply(hDlg); break;
  113.                 case PSN_HELP: MyHelp(GetParent(hDlg), "Mouse"); break;
  114.             }
  115.             return TRUE;
  116.     }
  117.     return FALSE;
  118. }
  119.  
  120. /*------------------------------------------------
  121.   notify parent window to enable "Apply" button
  122. --------------------------------------------------*/
  123. void SendPSChanged(HWND hDlg)
  124. {
  125.     if(m_bInit)
  126.     {
  127.         g_bApplyMain = TRUE;
  128.         m_bChanged = TRUE;
  129.         SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)(hDlg), 0);
  130.     }
  131. }
  132.  
  133. /*------------------------------------------------
  134.   initialize
  135. --------------------------------------------------*/
  136. void OnInit(HWND hDlg)
  137. {
  138.     PMOUSESTRUCT pMSS;
  139.     RECT rc;
  140.     BOOL b;
  141.     int i;
  142.     
  143.     m_bInit = FALSE;
  144.     
  145.     if(GetMyRegLong(m_section, "ver031031", 0) == 0)
  146.     {
  147.         SetMyRegLong(m_section, "ver031031", 1);
  148.         ImportOldMouseFunc(); // common/mousestruct.c
  149.     }
  150.     
  151.     m_numMouseCommand = GetMyRegLong(m_section, "MouseNum", 0);
  152.     m_numOld = m_numMouseCommand;
  153.     
  154.     if(m_numMouseCommand == 0) m_numMouseCommand = 1;
  155.     
  156.     m_pMouseCommand = malloc(sizeof(MOUSESTRUCT) * m_numMouseCommand);
  157.     // common/mousestruct.c
  158.     LoadMouseFunc(m_pMouseCommand, m_numMouseCommand);
  159.     
  160.     // common/tclang.c
  161.     SetDialogLanguage(hDlg, "Mouse", g_hfontDialog);
  162.     
  163.     GetWindowRect(GetDlgItem(hDlg, IDC_MOUSEOPT), &rc);
  164.     m_widthOpt = rc.right - rc.left;
  165.     
  166.     CBAddString(hDlg, IDC_MOUSEBUTTON,
  167.         (LPARAM)MyString(IDS_LEFTBUTTON, "LButton"));
  168.     CBAddString(hDlg, IDC_MOUSEBUTTON,
  169.         (LPARAM)MyString(IDS_RIGHTBUTTONM, "RButton"));
  170.     CBAddString(hDlg, IDC_MOUSEBUTTON,
  171.         (LPARAM)MyString(IDS_MIDDLEBUTTONM, "MButton"));
  172.     CBAddString(hDlg, IDC_MOUSEBUTTON,
  173.         (LPARAM)MyString(IDS_XBUTTON1, "XButton1"));
  174.     CBAddString(hDlg, IDC_MOUSEBUTTON,
  175.         (LPARAM)MyString(IDS_XBUTTON2, "XButton2"));
  176.     
  177.     InitFunction(hDlg, IDC_MOUSEFUNC);
  178.     
  179.     pMSS = m_pMouseCommand;
  180.     for(i = 0; i < m_numMouseCommand; i++)
  181.     {
  182.         CBAddString(hDlg, IDC_NAMECLICK, (LPARAM)pMSS->name);
  183.         pMSS++;
  184.     }
  185.     
  186.     CBSetCurSel(hDlg, IDC_NAMECLICK, 0);
  187.     OnName(hDlg);
  188.     
  189.     b = GetMyRegLong(NULL, "RightClickMenu", TRUE);
  190.     b = GetMyRegLong(m_section, "RightClickMenu", b);
  191.     CheckDlgButton(hDlg, IDC_RCLICKMENU, b);
  192.     
  193.     m_bInit = TRUE;
  194. }
  195.  
  196. /*------------------------------------------------
  197.    WM_DESTROY message
  198. --------------------------------------------------*/
  199. void OnDestroy(HWND hDlg)
  200. {
  201.     if(m_pMouseCommand) free(m_pMouseCommand);
  202.     m_pMouseCommand = NULL;
  203. }
  204.  
  205. /*------------------------------------------------
  206.    apply - save settings
  207. --------------------------------------------------*/
  208. void OnApply(HWND hDlg)
  209. {
  210.     char section[20];
  211.     int i;
  212.     
  213.     if(!m_bChanged) return;
  214.     m_bChanged = FALSE;
  215.     
  216.     OnNameDropDown(hDlg);
  217.     
  218.     if(m_pMouseCommand && 0 <= m_nCurrent && m_nCurrent < m_numMouseCommand)
  219.         GetMouseCommandFromDlg(hDlg, (m_pMouseCommand + m_nCurrent));
  220.     
  221.     SetMyRegLong(m_section, "MouseNum", m_numMouseCommand);
  222.     if(m_pMouseCommand)
  223.         SaveMouseFunc(m_pMouseCommand, m_numMouseCommand);
  224.     
  225.     if(m_numMouseCommand < m_numOld)
  226.     {
  227.         for(i = m_numMouseCommand; i < m_numOld; i++)
  228.         {
  229.             wsprintf(section, "Mouse%d", i+1);
  230.             DelMyRegKey(section);
  231.         }
  232.     }
  233.     m_numOld = m_numMouseCommand;
  234.     
  235.     SetMyRegLong(m_section, "RightClickMenu",
  236.         IsDlgButtonChecked(hDlg, IDC_RCLICKMENU));
  237.     DelMyReg(NULL, "RightClickMenu");
  238. }
  239.  
  240. /*------------------------------------------------
  241.    "Name" is selected
  242. --------------------------------------------------*/
  243. void OnName(HWND hDlg)
  244. {
  245.     int index;
  246.     
  247.     if(m_pMouseCommand &&
  248.         0 <= m_nCurrent && m_nCurrent < m_numMouseCommand)
  249.         GetMouseCommandFromDlg(hDlg, m_pMouseCommand + m_nCurrent);
  250.     
  251.     index = CBGetCurSel(hDlg, IDC_NAMECLICK);
  252.     
  253.     if(m_pMouseCommand &&
  254.         0 <= index && index < m_numMouseCommand)
  255.     {
  256.         SetMouseCommandToDlg(hDlg, m_pMouseCommand + index);
  257.         OnFunction(hDlg, TRUE);
  258.         m_nCurrent = index;
  259.     }
  260. }
  261.  
  262. /*------------------------------------------------
  263.    combo box is about to be visible
  264.    set edited text to combo box
  265. --------------------------------------------------*/
  266. void OnNameDropDown(HWND hDlg)
  267. {
  268.     char name[BUFSIZE_NAME];
  269.     
  270.     if(!m_pMouseCommand ||
  271.         !(0 <= m_nCurrent && m_nCurrent < m_numMouseCommand)) return;
  272.     
  273.     GetDlgItemText(hDlg, IDC_NAMECLICK, name, BUFSIZE_NAME);
  274.     
  275.     if(strcmp(name, m_pMouseCommand[m_nCurrent].name) != 0)
  276.     {
  277.         CBDeleteString(hDlg, IDC_NAMECLICK, m_nCurrent);
  278.         CBInsertString(hDlg, IDC_NAMECLICK, m_nCurrent, name);
  279.         strcpy(m_pMouseCommand[m_nCurrent].name, name);
  280.     }
  281. }
  282.  
  283. /*------------------------------------------------
  284.   "Add"
  285. --------------------------------------------------*/
  286. void OnAdd(HWND hDlg)
  287. {
  288.     PMOUSESTRUCT pNew, pMSS;
  289.     int i;
  290.     
  291.     OnNameDropDown(hDlg);
  292.     
  293.     if(m_pMouseCommand &&
  294.         (0 <= m_nCurrent && m_nCurrent < m_numMouseCommand))
  295.         GetMouseCommandFromDlg(hDlg, (m_pMouseCommand + m_nCurrent));
  296.     
  297.     pNew = malloc(sizeof(MOUSESTRUCT)*(m_numMouseCommand+1));
  298.     for(i = 0; i < m_numMouseCommand && m_pMouseCommand; i++)
  299.         memcpy(pNew + i, m_pMouseCommand + i, sizeof(MOUSESTRUCT));
  300.     
  301.     pMSS = pNew + i;
  302.     memset(pMSS, 0, sizeof(MOUSESTRUCT));
  303.     wsprintf(pMSS->name, "Mouse%d", i+1);
  304.     pMSS->nClick = 1;
  305.     pMSS->nCommand = 0;
  306.     
  307.     CBAddString(hDlg, IDC_NAMECLICK, (LPARAM)pMSS->name);
  308.     CBSetCurSel(hDlg, IDC_NAMECLICK, i);
  309.     m_nCurrent = i;
  310.     
  311.     m_numMouseCommand++;
  312.     if(m_pMouseCommand) free(m_pMouseCommand);
  313.     m_pMouseCommand = pNew;
  314.     
  315.     if(m_numMouseCommand == 1)
  316.         EnableMousePageItems(hDlg);
  317.     
  318.     SetMouseCommandToDlg(hDlg, pMSS);
  319.     OnFunction(hDlg, FALSE);
  320.     
  321.     PostMessage(hDlg, WM_NEXTDLGCTL, 1, FALSE);
  322. }
  323.  
  324. /*------------------------------------------------
  325.   "Delete"
  326. --------------------------------------------------*/
  327. void OnDelete(HWND hDlg)
  328. {
  329.     PMOUSESTRUCT pNew;
  330.     int i, j;
  331.     
  332.     if(!m_pMouseCommand || m_numMouseCommand < 1) return;
  333.     if(!(0 <= m_nCurrent && m_nCurrent < m_numMouseCommand)) return;
  334.     
  335.     if(m_numMouseCommand > 1)
  336.     {
  337.         pNew = malloc(sizeof(MOUSESTRUCT)*(m_numMouseCommand-1));
  338.         for(i = 0, j = 0; i < m_numMouseCommand; i++)
  339.         {
  340.             if(i != m_nCurrent)
  341.             {
  342.                 memcpy(pNew + j, m_pMouseCommand + i, sizeof(MOUSESTRUCT));
  343.                 j++;
  344.             }
  345.         }
  346.         
  347.         CBDeleteString(hDlg, IDC_NAMECLICK, m_nCurrent);
  348.         
  349.         if(m_nCurrent == m_numMouseCommand - 1) m_nCurrent--;
  350.         CBSetCurSel(hDlg, IDC_NAMECLICK, m_nCurrent);
  351.         SetMouseCommandToDlg(hDlg, (pNew + m_nCurrent));
  352.         OnFunction(hDlg, TRUE);
  353.         
  354.         m_numMouseCommand--;
  355.         free(m_pMouseCommand);
  356.         m_pMouseCommand = pNew;
  357.     }
  358.     else
  359.     {
  360.         free(m_pMouseCommand); m_pMouseCommand = NULL;
  361.         m_numMouseCommand = 0;
  362.         m_nCurrent = -1;
  363.         
  364.         CBDeleteString(hDlg, IDC_NAMECLICK, 0);
  365.         EnableMousePageItems(hDlg);
  366.         SetMouseCommandToDlg(hDlg, NULL);
  367.         OnFunction(hDlg, FALSE);
  368.     }
  369.     
  370.     PostMessage(hDlg, WM_NEXTDLGCTL, 1, FALSE);
  371. }
  372.  
  373. /*------------------------------------------------
  374.    "Function" is selected
  375. --------------------------------------------------*/
  376. void OnFunction(HWND hDlg, BOOL bInit)
  377. {
  378.     RECT rc;
  379.     int command = CBGetItemData(hDlg, IDC_MOUSEFUNC,
  380.                     CBGetCurSel(hDlg, IDC_MOUSEFUNC));
  381.     
  382.     if(!bInit) SetDlgItemText(hDlg, IDC_MOUSEOPT, "");
  383.     
  384.     if(command == IDC_OPENFILE || command == IDC_MOUSECOPY ||
  385.         command == IDC_MONOFF || command == IDC_COMMAND)
  386.     {
  387.         if(command == IDC_OPENFILE)
  388.             SetDlgItemText(hDlg, IDC_LABMOUSEOPT,
  389.                 MyString(IDS_FILE, "File"));
  390.         else if(command == IDC_MOUSECOPY)
  391.             SetDlgItemText(hDlg, IDC_LABMOUSEOPT,
  392.                 MyString(IDS_FORMATCOPY, "FormatCopy"));
  393.         else if(command == IDC_MONOFF)
  394.             SetDlgItemText(hDlg, IDC_LABMOUSEOPT,
  395.                 MyString(IDS_MONOFFSEC, "MonOffSec"));
  396.         else if(command == IDC_COMMAND)
  397.             SetDlgItemText(hDlg, IDC_LABMOUSEOPT,
  398.                 MyString(IDS_NUMERO, "Numero"));
  399.         
  400.         ShowDlgItem(hDlg, IDC_LABMOUSEOPT, TRUE);
  401.         
  402.         GetWindowRect(GetDlgItem(hDlg, IDC_MOUSEOPT), &rc);
  403.         if(command == IDC_OPENFILE || command == IDC_MOUSECOPY)
  404.             SetWindowPos(GetDlgItem(hDlg, IDC_MOUSEOPT), NULL,
  405.                 0, 0, m_widthOpt, rc.bottom - rc.top,
  406.                 SWP_NOZORDER|SWP_NOMOVE|SWP_SHOWWINDOW);
  407.         else
  408.         {
  409.             SetWindowPos(GetDlgItem(hDlg, IDC_MOUSEOPT), NULL,
  410.                 0, 0, (rc.bottom - rc.top)*2, rc.bottom - rc.top,
  411.                 SWP_NOZORDER|SWP_NOMOVE|SWP_SHOWWINDOW);
  412.         }
  413.         
  414.         if(command == IDC_OPENFILE)
  415.             ShowDlgItem(hDlg, IDC_MOUSEOPTSANSHO, TRUE);
  416.         else
  417.             ShowDlgItem(hDlg, IDC_MOUSEOPTSANSHO, FALSE);
  418.     }
  419.     else
  420.     {
  421.         ShowDlgItem(hDlg, IDC_LABMOUSEOPT, FALSE);
  422.         ShowDlgItem(hDlg, IDC_MOUSEOPT, FALSE);
  423.         ShowDlgItem(hDlg, IDC_MOUSEOPTSANSHO, FALSE);
  424.     }
  425. }
  426.  
  427. /*------------------------------------------------
  428.   select file
  429. --------------------------------------------------*/
  430. void OnBrowse(HWND hDlg)
  431. {
  432.     char deffile[MAX_PATH], fname[MAX_PATH];
  433.     
  434.     GetDlgItemText(hDlg, IDC_MOUSEOPT, deffile, MAX_PATH);
  435.     
  436.     // common/selectfile.c
  437.     if(!SelectMyFile(g_hInst, hDlg, "All (*.*)\0*.*\0\0",
  438.         0, deffile, fname))
  439.         return;
  440.     
  441.     SetDlgItemText(hDlg, IDC_MOUSEOPT, fname);
  442.     PostMessage(hDlg, WM_NEXTDLGCTL, 1, FALSE);
  443.     SendPSChanged(hDlg);
  444. }
  445.  
  446. /*------------------------------------------------
  447.   set MOUSESTRUCT data to dialog
  448. --------------------------------------------------*/
  449. void SetMouseCommandToDlg(HWND hDlg, PMOUSESTRUCT pMSS)
  450. {
  451.     int i, count;
  452.     
  453.     if(!pMSS)
  454.     {
  455.         SetDlgItemText(hDlg, IDC_NAMECLICK, "");
  456.         CBSetCurSel(hDlg, IDC_MOUSEBUTTON, 0);
  457.         CheckRadioButton(hDlg, IDC_RADSINGLE, IDC_RADQUADRUPLE,
  458.             IDC_RADSINGLE);
  459.         CheckDlgButton(hDlg, IDC_MOUSECTRL,  FALSE);
  460.         CheckDlgButton(hDlg, IDC_MOUSESHIFT, FALSE);
  461.         CheckDlgButton(hDlg, IDC_MOUSEALT,   FALSE);
  462.         CBSetCurSel(hDlg, IDC_MOUSEFUNC, 0);
  463.         ShowDlgItem(hDlg, IDC_LABMOUSEOPT, FALSE);
  464.         ShowDlgItem(hDlg, IDC_MOUSEOPT, FALSE);
  465.         ShowDlgItem(hDlg, IDC_MOUSEOPTSANSHO, FALSE);
  466.         ShowDlgItem(hDlg, IDC_LABMOUSEOPT2, FALSE);
  467.         return;
  468.     }
  469.     
  470.     CBSetCurSel(hDlg, IDC_MOUSEBUTTON, pMSS->nButton);
  471.     
  472.     CheckRadioButton(hDlg, IDC_RADSINGLE, IDC_RADQUADRUPLE,
  473.         IDC_RADSINGLE + pMSS->nClick - 1);
  474.     
  475.     CheckDlgButton(hDlg, IDC_MOUSECTRL,  pMSS->bCtrl);
  476.     CheckDlgButton(hDlg, IDC_MOUSESHIFT, pMSS->bShift);
  477.     CheckDlgButton(hDlg, IDC_MOUSEALT,   pMSS->bAlt);
  478.     
  479.     CBSetCurSel(hDlg, IDC_MOUSEFUNC, 0);
  480.     count = CBGetCount(hDlg, IDC_MOUSEFUNC);
  481.     for(i = 0; i < count; i++)
  482.     {
  483.         if(CBGetItemData(hDlg, IDC_MOUSEFUNC, i) == pMSS->nCommand)
  484.         {
  485.             CBSetCurSel(hDlg, IDC_MOUSEFUNC, i); break;
  486.         }
  487.     }
  488.     if(i == count && pMSS->nCommand > 100)
  489.     {
  490.         wsprintf(pMSS->option, "%d", pMSS->nCommand);
  491.         pMSS->nCommand = IDC_COMMAND;
  492.         for(i = 0; i < count; i++)
  493.         {
  494.             if(CBGetItemData(hDlg, IDC_MOUSEFUNC, i) == IDC_COMMAND)
  495.             {
  496.                 CBSetCurSel(hDlg, IDC_MOUSEFUNC, i); break;
  497.             }
  498.         }
  499.     }
  500.     
  501.     SetDlgItemText(hDlg, IDC_MOUSEOPT, pMSS->option);
  502. }
  503.  
  504. /*------------------------------------------------
  505.   get MOUSESTRUCT data from dialog
  506. --------------------------------------------------*/
  507. void GetMouseCommandFromDlg(HWND hDlg, PMOUSESTRUCT pMSS)
  508. {
  509.     int i;
  510.     
  511.     if(!pMSS) return;
  512.     
  513.     pMSS->nButton = CBGetCurSel(hDlg, IDC_MOUSEBUTTON);
  514.     
  515.     for(i = 0; i < 4; i++)
  516.     {
  517.         if(IsDlgButtonChecked(hDlg, IDC_RADSINGLE + i))
  518.         {
  519.             pMSS->nClick = i + 1;
  520.             break;
  521.         }
  522.     }
  523.     
  524.     pMSS->bCtrl  = IsDlgButtonChecked(hDlg, IDC_MOUSECTRL);
  525.     pMSS->bShift = IsDlgButtonChecked(hDlg, IDC_MOUSESHIFT);
  526.     pMSS->bAlt   = IsDlgButtonChecked(hDlg, IDC_MOUSEALT);
  527.     
  528.     pMSS->nCommand = CBGetItemData(hDlg, IDC_MOUSEFUNC,
  529.             CBGetCurSel(hDlg, IDC_MOUSEFUNC));
  530.     GetDlgItemText(hDlg, IDC_MOUSEOPT, pMSS->option, MAX_PATH);
  531. }
  532.  
  533. /*------------------------------------------------
  534.   enable/disable all dialog items
  535. --------------------------------------------------*/
  536. void EnableMousePageItems(HWND hDlg)
  537. {
  538.     HWND hwnd;
  539.     BOOL b = (m_pMouseCommand != NULL);
  540.     
  541.     hwnd = GetWindow(hDlg, GW_CHILD);
  542.     while(hwnd)
  543.     {
  544.         if(GetDlgCtrlID(hwnd) == IDC_RCLICKMENU) break;
  545.         
  546.         if(GetDlgCtrlID(hwnd) != IDC_ADDCLICK)
  547.             EnableWindow(hwnd, b);
  548.         hwnd = GetWindow(hwnd, GW_HWNDNEXT);
  549.     }
  550. }
  551.  
  552. /*------------------------------------------------
  553.    initialize "Function" combobox
  554. --------------------------------------------------*/
  555.  
  556. #define MAX_MOUSEFUNC 14
  557.  
  558. static struct {
  559.     int   idStr;
  560.     char *entry;
  561.     int   nCommand;
  562. } m_mousefunc[MAX_MOUSEFUNC] = {
  563.     { IDS_NONE,        "None",       0 },
  564.     { IDS_OPENFILE,    "OpenFile",   IDC_OPENFILE  },
  565.     { IDS_MOUSECOPY,   "MouseCopy",  IDC_MOUSECOPY },
  566.     { IDS_SYNCTIME,    "SyncTime",   IDC_SYNCTIME },
  567.     { IDS_TCLOCKMENU,  "TClockMenu", IDC_TCLOCKMENU },
  568.     { IDS_PROPDATE,    "PropDate",   IDC_DATETIME },
  569.     { IDS_EXITWIN,     "ExitWin",    IDC_EXITWIN },
  570.     { IDS_RUN,         "Run",        IDC_RUNAPP },
  571.     { IDS_ALLMIN,      "AllMin",     IDC_MINALL },
  572.     { IDS_SHOWDESK,    "ShowDesk",   IDC_SHOWDESK },
  573.     { IDS_SCREENSAVER, "SSaver",     IDC_SCREENSAVER },
  574.     { IDS_MONOFF,      "MonOff",     IDC_MONOFF },
  575.     { IDS_KYU,         "Kyu",        IDC_KYU },
  576.     { IDS_TCCOMMAND,   "TCCmd",      IDC_COMMAND },
  577. };
  578.  
  579. void InitFunction(HWND hDlg, int id)
  580. {
  581.     int index;
  582.     int i;
  583.     
  584.     for(i = 0; i < MAX_MOUSEFUNC; i++)
  585.     {
  586.         index = CBAddString(hDlg, id,
  587.             (LPARAM)MyString(m_mousefunc[i].idStr, m_mousefunc[i].entry));
  588.         CBSetItemData(hDlg, id, index, m_mousefunc[i].nCommand);
  589.     }
  590. }
  591.